package com.book.controller;


import com.book.pojo.Chapter;
import com.book.pojo.ChapterContent;
import com.book.result.Result;
import com.book.service.ChapterContentService;
import com.book.service.ChapterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
<<<<<<< HEAD
 * @author cxy
 * @since 2023-10-11 23:21:45
=======
 * @author cc
 * @since 2023-10-11 22:05:52
>>>>>>> a45ef284ff029011b55ef4d830c2b996023ef30c
 */
@RestController
@RequestMapping("/chapter")
public class ChapterController {

    @Autowired
    private ChapterService chapterService;

    //增加章节同时增加章节内容
    @PostMapping("addChapter")
    public Result addChapter(@RequestBody Chapter chapter){
        chapterService.addChapter(chapter);
        return Result.OK();
    }

    @PutMapping("updateChapter")
    public Result updateChapter(@RequestBody Chapter chapter){
        chapterService.updateChapter(chapter);
        return Result.OK();
    }

    //删除章节同时删除章节内容
    @DeleteMapping("deleteChapter")
    public Result deleteChapter(@RequestBody Long id){
        chapterService.deleteChapter(id);
        return Result.OK();
    }
}
